package
{
	import org.flixel.*;

	public class Snoop extends FlxSprite		//Class declaration for the squid monster class
	{
		private var skills:Array;
		static private var skillIndex:uint;
		private var shotClock:Number;
		private var originalX:int;				
		
		[Embed(source="salvavidas.png")] private var ImgSnoop:Class;	//The graphic of the squid monster
		
		public function Snoop(_skills:Array)
		{		
			super(FlxG.width /2,108);
			
			loadGraphic(ImgSnoop,true);
			
			shotClock = 1 + FlxU.random()*10;
			
			skills = _skills;
			skillIndex = 0;		
			velocity.x = 30;
			shotClock
		}
		
		override public function update():void
		{
			if(x < 8 )
			{
				x = 8;
				velocity.x = 30;
			}
			
			if(x > FlxG.width - (width + 8))
			{
				x = FlxG.width - (width + 8);
				velocity.x = - 30;
			}
	
			
			if(shotClock <= 0)
			{	
				

				var b:Skill = skills[skillIndex];
				b.reset(x + width / 2 - b.width, y + (height /2));
				b.velocity.y = 80;
				b.velocity.x = 0;
				
				skillIndex++;
				if(skillIndex >= skills.length) {
					skillIndex = 0;
				}
				
				shotClock = FlxU.random()*10;
			}
			
			super.update();
			
			shotClock -= FlxG.elapsed;
		}

	}
}